package com.android.phoenix.activity.changeInfo;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.NumberPicker;
import android.widget.NumberPicker.OnValueChangeListener;
import android.widget.TextView;

import com.android.phoenix.Constant;
import com.android.phoenix.MainApplication;
import com.android.phoenix.R;
import com.android.phoenix.activity.BaseActivity;

public class ChangeAgeActivity extends BaseActivity{
	private TextView tvCenter;
	private ImageView imgBack; 
	private NumberPicker numUserAge;
	private int userAge ;
	private SharedPreferences mShare;
	private Button btnConfirm;
	private TextView title_txt_right_up;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.acti_user_change_age);
		mShare = MainApplication.mSharedPreferences;
		userAge = mShare.getInt(Constant.USERAGE, 20);
		tvCenter = (TextView) findViewById(R.id.title_txt_center);
		tvCenter.setText(getResources().getString(R.string.txt_myinfo_change_age));
		title_txt_right_up = (TextView) findViewById(R.id.title_txt_right_up);
		title_txt_right_up.setVisibility(View.GONE);
		
		btnConfirm = (Button) findViewById(R.id.btnConfirm);
		
		numUserAge = (NumberPicker) findViewById(R.id.numUserAge);
		numUserAge.setMaxValue(100);
		numUserAge.setMinValue(0);
		numUserAge.setValue(mShare.getInt(Constant.USERAGE, 20));
		numUserAge.setOnValueChangedListener(new OnValueChangeListener() {
			
			@Override
			public void onValueChange(NumberPicker v, int arg1, int newAge) {
				userAge = newAge;
			}
		});
		
		imgBack = (ImageView) findViewById(R.id.title_Imgbtn_left_up);
		imgBack.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				finish();
			}
		});
		
		btnConfirm.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				mShare = MainApplication.mSharedPreferences;
				mShare.edit().putInt(Constant.USERAGE, userAge).commit();
				finish();
			}
		});
		
	}
}
